package com.gyd.marte;

import java.text.MessageFormat;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;

import com.gyd.dto.User;
import com.gyd.sqlite.UserSQLiteHelper;
import com.gyd.utils.PosicionGPS;

import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
import android.app.Activity;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

public class InitialActivity extends Activity {

	TextView latitud;
	TextView longitud;
	PosicionGPS PosGps;
		 private static final String SOAP_ACTION = "DefaultNamespace";
	     private static final String METHOD_NAME = "getEmpresass";
	     private static final String NAMESPACE = "urn:DefaultNamespace";
	     private static final String URL = "http://192.168.1.3:8080/WSMONGO/services/MARTEmongo";
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		String methodName="InitialActivity.onCreate()";
		setContentView(R.layout.activity_inicial);
		latitud = (TextView) findViewById(R.id.latitud);
		longitud = (TextView) findViewById(R.id.longitud);
		//latitud.setText("Latitude:");

		iniciar_app();
		SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);           

        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.dotNet=false;
        envelope.setOutputSoapObject(request);

        HttpTransportSE ht = new HttpTransportSE(URL);


        try{
            ht.call(SOAP_ACTION, envelope);
            //tv.setText("http set");
            //SoapPrimitive sp= (SoapPrimitive) envelope.getResponse();
            
            String sp=  envelope.getResponse().toString();
            //String sp=  ":";//envelope.getResponse().toString();
            //latitud.setText("Msg from service: "+sp);


        }
        catch(Exception e)
        {
        	Log.i("INFOTAG", methodName+e);
            e.printStackTrace();
        }

	}

	
	public void iniciar_app() {
		PosGps = new PosicionGPS(this, latitud, longitud);
		PosGps.start();
	}

	public void cerrar(View view) {
		finish();
	}


	}
